package com.vonchange.purchase.good.action;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.vonchange.headb.core.map.HeaMap;
import com.vonchange.headb.core.page.IPage;
import com.vonchange.purchase.good.bean.Good;
import com.vonchange.purchase.good.service.IGoodService;
import com.vonchange.utils.page.PageUtils;
import com.vonchange.utils.web.RequestUtils;

@Controller
@RequestMapping("/good")
public class GoodAction {
	@Resource
	private IGoodService goodService;
	@RequestMapping("/findById")
	@ResponseBody
	public Good findById(@RequestParam("id")String id){
		return goodService.findById(id);
	}
	@RequestMapping("/findList")
	@ResponseBody
	public List<Good> findList(HttpServletRequest request,HttpServletResponse response){
		Map<String, Object> paramMap= RequestUtils.getQueryParams(request);
		return goodService.findList(new HeaMap().setAll(paramMap));
	}
	@RequestMapping("/findPage")
	@ResponseBody
	public IPage<Good> findPage(Integer pageNo,Integer pageSize,HttpServletRequest request,HttpServletResponse response){
		Map<String, Object> paramMap= RequestUtils.getQueryParams(request);
		IPage<Good> page=PageUtils.initPage(pageNo, pageSize);
		return goodService.findPage(page,new HeaMap().setAll(paramMap));
	}
}
